package cn.hxth.cloud.api.mapper;


import cn.hxth.cloud.api.domain.User;
import cn.hxth.cloud.api.tk.mapper.MyMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@org.apache.ibatis.annotations.Mapper
public interface UserMapper extends MyMapper<User> {
   /* @Results(id = "userMap",
            value = {
                    @Result(id = true ,property = "id" ,column = "id"),
                    @Result(property = "name" ,column = "name"),
                    @Result(property = "age",column = "age"),
                    @Result(property = "date",column = "date")
            }
    )*/

    @Select({"SELECT user_name FROM user"})
    public List<User> list() ;
/*    @ResultMap("userMap")*/
    @Select("SELECT * FROM  user WHERE id=#{value}")
    public  User get(Long id) ;
    @Update("<script>" +
            "UPDATE  user SET user_name=#{name} WHERE id IN " +
            "<foreach collection='ids' item='id'  open='(' close=')' separator=','>"+
            " #{id}"+
             "</foreach>"+
            "</script>" )
    public  Integer updateName(@Param("name") String name, @Param("ids") List<Long> ids) ;

}